<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Dashboard Template for Bootstrap</title>
	<!-- 导入公共的样式 -->
	<section th:replace="~{common/css :: #cssSection}"></section>
</head>

<body>

    <!-- 导入公共的顶部导航条 -->
    <div th:replace="~{common/navigation :: topNav}"></div>

<div class="container-fluid">
    <div class="row">
		<!-- 导入公共的左侧导航条 -->
		<div th:replace="~{common/navigation :: leftNav(menuName='empList')}"></div>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <form action="" th:action="@{/manage/emp}" method="post">
                <!-- 使用隐藏框传递员工id -->
                <input type="hidden" name="id" th:value="${employee != null} ? ${employee.id}" th:if="${employee != null}">
                <!-- 将post请求改造成put请求-->
                <input type="hidden" name="_method" value="put" th:if="${employee != null}">

                <div class="form-group">
                    <label>LastName</label>
                    <input name="empName" type="text" class="form-control" th:value="${employee != null} ? ${employee.empName}">
                </div>
                <div class="form-group">
                    <label>Email</label>
                    <input name="email" type="email" class="form-control" th:value="${employee != null} ? ${employee.email}">
                </div>
                <div class="form-group">
                    <label>Gender</label><br/>
                    <div class="form-check form-check-inline">
                        <input class="form-check-input" type="radio" name="gender" value="1" checked th:checked="${employee != null} ? ${employee.gender} == 1 : true">
                        <label class="form-check-label">男</label>
                    </div>
                    <div class="form-check form-check-inline">
                        <input class="form-check-input" type="radio" name="gender" value="0" th:checked="${employee != null} ? ${employee.gender} == 0">
                        <label class="form-check-label">女</label>
                    </div>
                </div>
                <div class="form-group">
                    <label>department</label>
                    <!--提交的是部门的id-->
                    <select class="form-control" name="deptId">
                        <option value="1" th:each="dept : ${deptList}" th:text="${dept.departmentName}" th:value="${dept.id}" th:selected="${employee != null} ? ${employee.deptId} == ${dept.id}">1</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>Birth</label>
                    <input name="birth" type="text" class="form-control" th:value="${employee != null} ? ${#dates.format(employee.birth,'yyyy-MM-dd')}">
                </div>
                <button type="submit" class="btn btn-primary" th:text="${employee != null} ? '修改' : '添加'">添加</button>
            </form>
        </main>
    </div>
</div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" src="asserts/js/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="asserts/js/popper.min.js"></script>
<script type="text/javascript" src="asserts/js/bootstrap.min.js"></script>

<!-- Icons -->
<script type="text/javascript" src="asserts/js/feather.min.js"></script>
<script>
    feather.replace()
</script>

</body>
</html>